<?php

class Education extends AppModel
{

	public $name = 'Education';

	public $displayField = 'name';

	public $validate = array(
        'name' => array(
            'create_first' => array(
                'on' => 'create',
                'required' => true,
                'allowEmpty' => false,
                'message' => 'required',
            ),
            'update_first' => array(
                'on' => 'update',
                'required' => false,
                'allowEmpty' => false,
                'message' => 'required',
            ),
        ),
	);

	public $hasMany = array(
		'Candidates' => array('className' => 'Candidate',
            'dependent' => false,
        ),
	);

	function allowDelete($fields = null)
	{
	    if (!isset($fields)) {
	        return true;
	    }
	    if (empty($fields[$this->primaryKey])) {
	        return false;
	    }
	    $this->Candidates->rel();
        return !(bool)$this->Candidates->find(array("`".Inflector::underscore($this->name)."_id`" => $fields[$this->primaryKey]));
	}

	function allowUpdate($fields = null)
	{
        return true;
	}

	function generateList($conds = array())
	{
	    $this->rel();
        return parent::generateList($conds, $this->primaryKey, null, "{n}.{$this->name}.{$this->primaryKey}", "{n}.{$this->name}.{$this->displayField}");
	}
}

?>